'''
Created on 24-Apr-2013

@author: cdac
'''

from SMS.DataSource import DataSource
from SMS.PreprocessSMS import PreprocessSMS
from SMS.Stats import Stats
from Plotting.StatsPlot import StatsPlot

class WordFrequencyExp():
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        pass
   
    def experiment(self):
        pass

       
        
if __name__ == '__main__':

    small_ham_file  = '../Data/HamSmall.csv'
    small_spam_file = '../Data/SpamSmall.csv'

    large_ham_file  = '../Data/Ham.csv'
    large_spam_file = '../Data/Spam.csv'
    
#     ds = DataSource(large_ham_file, large_spam_file)
    ds_ham = DataSource(large_ham_file)
    ds_spam = DataSource(large_spam_file)


    # Get all msgs in ham and spam
    hams    = ds_ham.getHams()
    spams   = ds_spam.getSpams()

    exp_range = range(20,500,20)
  
    for sample in exp_range:
        
        # Get random msgs in ham and spam
        hams    = ds_ham.get_random_msgs(how_many=sample);
        spams   = ds_spam.get_random_msgs(how_many= sample)
    
        ham_stats_raw = Stats(hams, "HamStatsRaw" + str(sample))
        #ham_stats_raw.dump_stats()
        
        spam_stats_raw = Stats(spams, "SpamStatsRaw" + str(sample))
        #spam_stats_raw.dump_stats()
    
        # Preprocess ham and spam by removing punctuations and
        # special characters
        processor = PreprocessSMS()
          
        hams = processor.remove_puncts_and_special_chars(hams)
        hams = processor.convert_to_lowercase(hams)

        spams = processor.remove_puncts_and_special_chars(spams)
        spams = processor.convert_to_lowercase(spams)
        
        ham_stats_prep = Stats(hams, "HamStatsPrep" + str(sample))
        #ham_stats_prep.dump_stats()
    
        spam_stats_prep = Stats(spams, "SpamStatsPrep" + str(sample))
        #spam_stats_prep.dump_stats()
    
        # Remove all stopwords from samples
        hams = processor.remove_stopwords(hams)
        spams = processor.remove_stopwords(spams)

        ham_stats_no_sw= Stats(hams, "HamStatsNoSW" + str(sample))
        #ham_stats_no_sw.dump_stats()
    
        spam_stats_no_sw = Stats(spams, "SpamStatsNoSW" + str(sample))
        #spam_stats_no_sw.dump_stats()
        print spam_stats_no_sw.print_stats()

        
    statsPlot = StatsPlot()
    
    